From: Colin Walters Date: Wed, 16 Jul 2025 16:56:49 +0000 (-0400) Subject: prepare-root: Rename rootfs variables X-Git-Tag: archive/raspbian/2025.7-2+rpi1^2^2~6^2~3^2~4^2~2 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=d0f4d79dd38cfca6d9011ccbc6bd39686de9c899;p=ostree.git prepare-root: Rename rootfs variables Prep for moving more functionality there, it's really about the rootfs, not just composefs. Signed-off-by: Colin Walters --- diff --git a/src/libostree/ostree-soft-reboot.c b/src/libostree/ostree-soft-reboot.c index d4c6e3a4..2c728a3c 100644 --- a/src/libostree/ostree-soft-reboot.c +++ b/src/libostree/ostree-soft-reboot.c @@ -56,12 +56,12 @@ _ostree_prepare_soft_reboot (GError **error) return FALSE; g_autofree char *kernel_cmdline = read_proc_cmdline (); - g_autoptr (RootConfig) composefs_config + g_autoptr (RootConfig) rootfs_config = otcore_load_rootfs_config (kernel_cmdline, config, TRUE, error); - if (!composefs_config) + if (!rootfs_config) return FALSE; - if (composefs_config->enabled != OT_TRISTATE_YES) + if (rootfs_config->enabled != OT_TRISTATE_YES) return glnx_throw (error, "soft reboot not supported without composefs"); GVariantBuilder metadata_builder; @@ -72,7 +72,7 @@ _ostree_prepare_soft_reboot (GError **error) // Tracks if we did successfully enable it at runtime bool using_composefs = false; - if (!otcore_mount_rootfs (composefs_config, &metadata_builder, root_transient, sysroot_path, + if (!otcore_mount_rootfs (rootfs_config, &metadata_builder, root_transient, sysroot_path, target_deployment, OTCORE_RUN_NEXTROOT, &using_composefs, error)) return glnx_prefix_error (error, "failed to mount composefs"); diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c index 92176bd7..749436bd 100644 --- a/src/libostree/ostree-sysroot-deploy.c +++ b/src/libostree/ostree-sysroot-deploy.c @@ -656,12 +656,12 @@ checkout_deployment_tree (OstreeSysroot *sysroot, OstreeRepo *repo, const char * // out if it's enabled, but not supported at compile time. // However, we don't load the keys here, because they may not exist, such // as in the initial deploy - g_autoptr (RootConfig) composefs_config + g_autoptr (RootConfig) rootfs_config = otcore_load_rootfs_config ("", prepare_root_config, FALSE, error); - if (!composefs_config) - return glnx_prefix_error (error, "Reading composefs config"); + if (!rootfs_config) + return glnx_prefix_error (error, "Reading rootfs config"); - OtTristate composefs_enabled = composefs_config->enabled; + OtTristate composefs_enabled = rootfs_config->enabled; g_debug ("composefs enabled by config: %d repo: %d", composefs_enabled, repo->composefs_wanted); if (repo->composefs_wanted == OT_TRISTATE_YES) composefs_enabled = repo->composefs_wanted; @@ -680,7 +680,7 @@ checkout_deployment_tree (OstreeSysroot *sysroot, OstreeRepo *repo, const char * g_auto (GVariantBuilder) cfs_checkout_opts_builder = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_VARDICT); guint32 composefs_requested = 1; - if (composefs_config->require_verity) + if (rootfs_config->require_verity) composefs_requested = 2; g_variant_builder_add (&cfs_checkout_opts_builder, "{sv}", "verity", g_variant_new_uint32 (composefs_requested)); diff --git a/src/libotcore/otcore-prepare-root.c b/src/libotcore/otcore-prepare-root.c index 0a147a67..98cb51d5 100644 --- a/src/libotcore/otcore-prepare-root.c +++ b/src/libotcore/otcore-prepare-root.c @@ -428,7 +428,7 @@ otcore_mount_etc (GKeyFile *config, GVariantBuilder *metadata_builder, const cha } gboolean -otcore_mount_rootfs (RootConfig *composefs_config, GVariantBuilder *metadata_builder, +otcore_mount_rootfs (RootConfig *rootfs_config, GVariantBuilder *metadata_builder, gboolean root_transient, const char *root_mountpoint, const char *deploy_path, const char *mount_target, bool *out_using_composefs, GError **error) { @@ -450,7 +450,7 @@ otcore_mount_rootfs (RootConfig *composefs_config, GVariantBuilder *metadata_bui #ifdef HAVE_COMPOSEFS /* We construct the new sysroot in /sysroot.tmp, which is either the composefs mount or a bind mount of the deploy-dir */ - if (composefs_config->enabled == OT_TRISTATE_NO) + if (rootfs_config->enabled == OT_TRISTATE_NO) return TRUE; g_autofree char *sysroot_objects = g_strdup_printf ("%s/ostree/repo/objects", root_mountpoint); @@ -492,9 +492,9 @@ otcore_mount_rootfs (RootConfig *composefs_config, GVariantBuilder *metadata_bui cfs_options.flags = LCFS_MOUNT_FLAGS_READONLY; } - if (composefs_config->is_signed) + if (rootfs_config->is_signed) { - const char *composefs_pubkey = composefs_config->signature_pubkey; + const char *composefs_pubkey = rootfs_config->signature_pubkey; g_autoptr (GVariant) commit = NULL; g_autoptr (GVariant) commitmeta = NULL; @@ -507,7 +507,7 @@ otcore_mount_rootfs (RootConfig *composefs_config, GVariantBuilder *metadata_bui return glnx_throw (error, "Signature validation requested, but no signatures in commit"); g_autoptr (GBytes) commit_data = g_variant_get_data_as_bytes (commit); - if (!validate_signature (commit_data, signatures, composefs_config->pubkeys, error)) + if (!validate_signature (commit_data, signatures, rootfs_config->pubkeys, error)) return glnx_prefix_error (error, "No valid signatures found for public key"); g_print ("composefs+ostree: Validated commit signature using '%s'\n", composefs_pubkey); @@ -526,12 +526,12 @@ otcore_mount_rootfs (RootConfig *composefs_config, GVariantBuilder *metadata_bui expected_digest = g_malloc (OSTREE_SHA256_STRING_LEN + 1); ot_bin2hex (expected_digest, cfs_digest_buf, g_variant_get_size (cfs_digest_v)); - g_assert (composefs_config->require_verity); + g_assert (rootfs_config->require_verity); cfs_options.flags |= LCFS_MOUNT_FLAGS_REQUIRE_VERITY; g_print ("composefs: Verifying digest: %s\n", expected_digest); cfs_options.expected_fsverity_digest = expected_digest; } - else if (composefs_config->require_verity) + else if (rootfs_config->require_verity) { cfs_options.flags |= LCFS_MOUNT_FLAGS_REQUIRE_VERITY; } @@ -549,8 +549,8 @@ otcore_mount_rootfs (RootConfig *composefs_config, GVariantBuilder *metadata_bui else { int errsv = errno; - g_assert (composefs_config->enabled != OT_TRISTATE_NO); - if (composefs_config->enabled == OT_TRISTATE_MAYBE && errsv == ENOENT) + g_assert (rootfs_config->enabled != OT_TRISTATE_NO); + if (rootfs_config->enabled == OT_TRISTATE_MAYBE && errsv == ENOENT) { g_print ("composefs: No image present\n"); } @@ -562,7 +562,7 @@ otcore_mount_rootfs (RootConfig *composefs_config, GVariantBuilder *metadata_bui } #else /* if composefs is configured as "maybe", we should continue */ - if (composefs_config->enabled == OT_TRISTATE_YES) + if (rootfs_config->enabled == OT_TRISTATE_YES) return glnx_throw (error, "composefs: enabled at runtime, but support is not compiled in"); #endif *out_using_composefs = using_composefs; diff --git a/src/libotcore/otcore.h b/src/libotcore/otcore.h index 82dfae90..070498a2 100644 --- a/src/libotcore/otcore.h +++ b/src/libotcore/otcore.h @@ -80,7 +80,7 @@ RootConfig *otcore_load_rootfs_config (const char *cmdline, GKeyFile *config, gb /** * otcore_mount_rootfs: - * @composefs_config: Configuration for composefs. + * @rootfs_config: Configuration for root * @metadata_builder: (transfer none): GVariantBuilder to add metadata to. * @root_transient: Whether the root filesystem is transient. * @root_mountpoint: The mount point of the physical root filesystem. @@ -94,7 +94,7 @@ RootConfig *otcore_load_rootfs_config (const char *cmdline, GKeyFile *config, gb * * Returns: %TRUE on success, %FALSE on error. */ -gboolean otcore_mount_rootfs (RootConfig *composefs_config, GVariantBuilder *metadata_builder, +gboolean otcore_mount_rootfs (RootConfig *rootfs_config, GVariantBuilder *metadata_builder, gboolean root_transient, const char *root_mountpoint, const char *deploy_path, const char *mount_target, bool *out_using_composefs, GError **error); diff --git a/src/switchroot/ostree-prepare-root.c b/src/switchroot/ostree-prepare-root.c index 7eeeb7f4..45899727 100644 --- a/src/switchroot/ostree-prepare-root.c +++ b/src/switchroot/ostree-prepare-root.c @@ -192,14 +192,14 @@ main (int argc, char *argv[]) // We always parse the composefs config, because we want to detect and error // out if it's enabled, but not supported at compile time. - g_autoptr (RootConfig) composefs_config + g_autoptr (RootConfig) rootfs_config = otcore_load_rootfs_config (kernel_cmdline, config, TRUE, &error); - if (!composefs_config) + if (!rootfs_config) errx (EXIT_FAILURE, "%s", error->message); // If composefs is enabled, that also implies sysroot.readonly=true because it's // the new default we want to use (not because it's actually required) - const bool sysroot_readonly_default = composefs_config->enabled == OT_TRISTATE_YES; + const bool sysroot_readonly_default = rootfs_config->enabled == OT_TRISTATE_YES; if (!ot_keyfile_get_boolean_with_default (config, SYSROOT_KEY, READONLY_KEY, sysroot_readonly_default, &sysroot_readonly, &error)) errx (EXIT_FAILURE, "Failed to parse sysroot.readonly value: %s", error->message); @@ -231,7 +231,7 @@ main (int argc, char *argv[]) * However, we only do this if composefs is not enabled, because we don't * want to parse the target root filesystem before verifying its integrity. */ - if (!sysroot_readonly && composefs_config->enabled != OT_TRISTATE_YES) + if (!sysroot_readonly && rootfs_config->enabled != OT_TRISTATE_YES) { sysroot_readonly = sysroot_is_configured_ro (root_arg); // Encourage porting to the new config file @@ -263,7 +263,7 @@ main (int argc, char *argv[]) // Tracks if we did successfully enable it at runtime bool using_composefs = false; - if (!otcore_mount_rootfs (composefs_config, &metadata_builder, root_transient, root_mountpoint, + if (!otcore_mount_rootfs (rootfs_config, &metadata_builder, root_transient, root_mountpoint, deploy_path, TMP_SYSROOT, &using_composefs, &error)) errx (EXIT_FAILURE, "Failed to mount composefs: %s", error->message); @@ -316,7 +316,7 @@ main (int argc, char *argv[]) * Also, hotfixes are incompatible with signed composefs use for security reasons. */ if (lstat (OTCORE_HOTFIX_USR_OVL_WORK, &stbuf) == 0 - && !(using_composefs && composefs_config->is_signed)) + && !(using_composefs && rootfs_config->is_signed)) { /* Do we have a persistent overlayfs for /usr? If so, mount it now. */ const char usr_ovl_options[]